<template>
  <!-- <a-card :bordered="false"> -->
    <!-- table区域-begin -->
    <div>
      <a-table
        size="small"
        row-key="id"
        :columns="columns"
        :data-source="dataSource"
        :pagination="false"
        :loading="loading"
        @change="handleTableChange"
      >
        <template slot="action" slot-scope="text, record">
          <a-popconfirm title="确定拾取任务吗?" @confirm="() => handleClaimTask(record)">
            <a >拾取</a>
          </a-popconfirm>
          <a-divider type="vertical" />
          <a @click="handleDetails(record)">详情</a>
        </template>
      </a-table>
      <task-modal ref="taskModal" title="详情" :taskData="taskData" :type="type"></task-modal>
    </div>
  <!-- </a-card> -->
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { claimTask } from '@/api/task'
import taskModal from '@/views/modules/task/modal/TaskModal'
export default {
  name: 'teamTask',
  components: {
    taskModal
  },
  mixins: [JeecgListMixin],
  data() {
    return {
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '流程名称',
          align: 'center',
          dataIndex: 'modelName',
          ellipsis: true
        },
        {
          title: '流程编码',
          align: 'center',
          dataIndex: 'modelKey'
        },
        {
          title: '业务标题',
          align: 'center',
          dataIndex: 'instanceName',
          ellipsis: true
        },
        {
          title: '发起人',
          align: 'center',
          dataIndex: 'creator'
        },
        {
          title: '开始时间',
          align: 'center',
          dataIndex: 'createTime'
        },
        {
          title: '当前环节',
          align: 'center',
          dataIndex: 'name',
          ellipsis: true
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        // list: '/activiti/task/getGroupTaskList'
        list: '/activiti/task/getMyAllTaskList'
      },
      queryParam: {
        taskType: 0
      },
      taskData: {},
      type: 'history_his',
      ipagination: {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + ' 共' + total + '条'
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      }
    }
  },
  methods: {
    handleClaimTask(record) { // 拾取流程
      claimTask({
        taskId: record.id
      }).then(res => {
        if (res.success) {
          this.loadData()
          this.$message.success(res.message)
        } else {
          this.$message.error(res.message)
        }
      })
    },
    handleDetails(data) {
      this.taskData = data
      this.$refs.taskModal.editModalVisible = true
    }
  }
}
</script>
<style scoped>
  @import '~@assets/less/common.less';

</style>
